package com.lenovo.agricultureServer.http.action;

import com.lenovo.agricultureServer.http.HttpConstant;

public abstract class BaseAction 
{
	//通信协议类型
	public static final String TYPE_JASON 	= "jason";
	public static final String TYPE_SOAP 	= "soap";
	
	private String type = "";
	
	public String getType() {
		return type;
	}
	public void setType(String type) {
		this.type = type;
	}
	
	public String porcessAction(String param)
	{
		String resultStr=null;
		if(type.equals(TYPE_JASON)){
			resultStr = jasonPorcess(param);
			if(resultStr==null){
				resultStr = "{'result':'failed'}";
			}
		} else if(type.equals(TYPE_SOAP)){
			resultStr = soapPorcess(param);
		} else {
			resultStr = "Protocol error";
		}
		if(resultStr==null){
			resultStr = HttpConstant.HTTP_INTERNALERROR;
		}
		return resultStr;
	}
	
	protected abstract String jasonPorcess(String param);
	protected abstract String soapPorcess(String param);
}
